<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   主题：R语言初学，关于包的问题  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript">
   MathJax.Hub.Config({elements: ["bbpress-forums"]});
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://cos.name/cn/topic/107532/",
                  host: "http://cos.name",
                  prePath: "http://cos.name",
                  scheme: "http",
                  pathBase: "http://cos.name/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466445559: Accept with keywords: (title(0.2):问题,R语言,主题,初学,论坛, topn(0.3):RSS订阅,软件应用,信息,帖子,开源,作者,会员,变量,用户名,主站,新鲜事,样本容量,计算结果,源代码,函数,问题,密码,普通,使用者,训练样本,版主,预测,主题,总计,期数,初学,论坛,软件,R语言,讨论区).-->
 </head>
 <body class="topic bbpress single single-topic postid-107532 single-author sidebar" onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    主题：R语言初学，关于包的问题
   </h1>
  </div>
  <div class="container" id="xmain">
   <div class="hfeed site" id="page">
    <header class="site-header" id="masthead" role="banner">
     <div id="cos-logo">
      <a href="http://cos.name/cn">
       <img src="http://cos.name/cn/wp-content/themes/COS-forest/images/headers/cos-logo.png"/>
      </a>
     </div>
     <div class="navbar" id="navbar">
      <nav class="navigation main-navigation" id="site-navigation" role="navigation">
       <h3 class="menu-toggle">
        菜单
       </h3>
       <div class="menu-%e8%8f%9c%e5%8d%951-container">
        <ul class="nav-menu" id="menu-%e8%8f%9c%e5%8d%951">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-407772" id="menu-item-407772">
          <a href="http://cos.name/cn/">
           论坛首页
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-407773" id="menu-item-407773">
          <a href="http://cos.name/cn/forums/">
           讨论区
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-407774" id="menu-item-407774">
          <a href="http://cos.name/cn/wp-login.php?action=register">
           注册
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-407819" id="menu-item-407819">
          <a href="http://cos.name/">
           主站
          </a>
         </li>
        </ul>
       </div>
      </nav>
      <!-- #site-navigation -->
     </div>
     <!-- #navbar -->
    </header>
    <!-- #masthead -->
    <div class="site-main" id="main">
     <div class="content-area" id="primary">
      <div class="site-content" id="content" role="main">
       <article class="post-107532 topic type-topic status-publish hentry" id="post-107532">
        <header class="entry-header">
         <h1 class="entry-title">
          R语言初学，关于包的问题
         </h1>
        </header>
        <!-- .entry-header -->
        <div class="entry-content">
         <div id="bbpress-forums">
          <div class="bbp-breadcrumb">
           <p>
            <a class="bbp-breadcrumb-home" href="http://cos.name/cn/">
             COS论坛 | 统计之都
            </a>
            <span class="bbp-breadcrumb-sep">
             ›
            </span>
            <a class="bbp-breadcrumb-root" href="http://cos.name/cn/forums/">
             讨论区
            </a>
            <span class="bbp-breadcrumb-sep">
             ›
            </span>
            <a class="bbp-breadcrumb-forum" href="http://cos.name/cn/forum/software/">
             软件应用
            </a>
            <span class="bbp-breadcrumb-sep">
             ›
            </span>
            <a class="bbp-breadcrumb-forum" href="http://cos.name/cn/forum/software/r-language/">
             S-Plus &amp; R语言
            </a>
            <span class="bbp-breadcrumb-sep">
             ›
            </span>
            <span class="bbp-breadcrumb-current">
             R语言初学，关于包的问题
            </span>
           </p>
          </div>
          <div class="bbp-template-notice info">
           <p class="bbp-topic-description">
            该主题包含 10 条回复，4个帖子，最后由
            <a class="bbp-author-avatar" href="http://cos.name/cn/profile/376339/" rel="nofollow" title="查看he_sophie的档案">
             <img src="http://sdn.geekzu.org/avatar/2dd480c72937d6c7c5c9f351c0b1b439?s=14&amp;d=monsterid&amp;r=g"/>
            </a>
            <a class="bbp-author-name" href="http://cos.name/cn/profile/376339/" rel="nofollow" title="查看he_sophie的档案">
             he_sophie
            </a>
            在
            <a href="http://cos.name/cn/topic/107532/#post-335594" title="回复：R语言初学，关于包的问题">
             3 年, 10 月 之前
            </a>
            更新。
           </p>
          </div>
          <div class="bbp-pagination">
           <div class="bbp-pagination-count">
            查看 11 个帖子 - 1 到 11（总计 11 个）
           </div>
           <div class="bbp-pagination-links">
           </div>
          </div>
          <ul class="forums bbp-replies" id="topic-107532-replies">
           <li class="bbp-header">
            <div class="bbp-reply-author">
             作者
            </div>
            <!-- .bbp-reply-author -->
            <div class="bbp-reply-content">
             帖子
            </div>
            <!-- .bbp-reply-content -->
           </li>
           <!-- .bbp-header -->
           <li class="bbp-body">
            <div class="bbp-reply-header" id="post-107532">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2012年7月21日 上午3:21
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/107532/#post-107532">
               1 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-107532 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-107532 bbp-reply-position-1 user-id-373814 topic-author post-107532 topic type-topic status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/373814/" rel="nofollow" title="查看vivihe的档案">
               <img src="http://sdn.geekzu.org/avatar/ee81d786a5d30d7fe9d2ec23c1ad4cac?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/373814/" rel="nofollow" title="查看vivihe的档案">
               vivihe
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               各位好，最近开始学R，有个疑问，R有很多package，这些package的质量如何控制呢？比如如何判断某一个package的权威性？里面的函数可靠么？
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-334838">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2012年7月21日 上午3:57
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/107532/#post-334838">
               2 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-334838 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-107532 bbp-reply-position-2 user-id-107675 post-334838 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/107675/" rel="nofollow" title="查看肖楠的档案">
               <img src="http://sdn.geekzu.org/avatar/66aa115466aeedf71937ff80c00b7982?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/107675/" rel="nofollow" title="查看肖楠的档案">
               肖楠
              </a>
              <br/>
              <div class="bbp-author-role">
               版主
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               冷暖自知。
              </p>
              <p>
               当然，R Core 和社区活跃贡献者写的通常比较靠谱；Reverse dependencies 多的比较靠谱；文档齐全，有 vignettes 的，在 R News / R Journal / JSS 发表过的比较靠谱。
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-334875">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2012年7月21日 下午2:56
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/107532/#post-334875">
               3 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-334875 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-107532 bbp-reply-position-3 user-id-376339 post-334875 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/376339/" rel="nofollow" title="查看he_sophie的档案">
               <img src="http://sdn.geekzu.org/avatar/2dd480c72937d6c7c5c9f351c0b1b439?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/376339/" rel="nofollow" title="查看he_sophie的档案">
               he_sophie
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               我发现np包里面的npregbw()函数的计算结果是随机的,设定同样的参数,样本观测值不变,但是返回的值却每次不尽相同.非常困惑.希望得到指点.谢谢!
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-334878">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2012年7月21日 下午3:14
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/107532/#post-334878">
               4 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-334878 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-107532 bbp-reply-position-4 user-id-107675 post-334878 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/107675/" rel="nofollow" title="查看肖楠的档案">
               <img src="http://sdn.geekzu.org/avatar/66aa115466aeedf71937ff80c00b7982?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/107675/" rel="nofollow" title="查看肖楠的档案">
               肖楠
              </a>
              <br/>
              <div class="bbp-author-role">
               版主
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               每次做之前都
               <code>
                set.seed(1234)
               </code>
               试试。
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-334922">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2012年7月22日 上午5:01
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/107532/#post-334922">
               5 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-334922 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-107532 bbp-reply-position-5 user-id-103183 post-334922 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/103183/" rel="nofollow" title="查看easttiger的档案">
               <img src="http://sdn.geekzu.org/avatar/abaead86be3dc59380199f1e9e35c5bb?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/103183/" rel="nofollow" title="查看easttiger的档案">
               easttiger
              </a>
              <br/>
              <div class="bbp-author-role">
               版主
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               R是开源软件, 开源软件对使用者的要求一项比较高. 开源的意义就是让使用者可以看到所有的源代码, 从而使完整了解整个程序到底在干什么成为可能. 开源软件要求使用者同时具备开发能力, 并充分信任这个能力, 所以没有权威组织出来说那个包是好的, 那个包是坏的.
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-334930">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2012年7月22日 上午7:25
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/107532/#post-334930">
               6 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-334930 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-107532 bbp-reply-position-6 user-id-376339 post-334930 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/376339/" rel="nofollow" title="查看he_sophie的档案">
               <img src="http://sdn.geekzu.org/avatar/2dd480c72937d6c7c5c9f351c0b1b439?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/376339/" rel="nofollow" title="查看he_sophie的档案">
               he_sophie
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               回复 第5楼 的 easttiger：在哪里可以看到源代码?谢谢!
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-334942">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2012年7月22日 上午11:22
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/107532/#post-334942">
               7 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-334942 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-107532 bbp-reply-position-7 user-id-103183 post-334942 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/103183/" rel="nofollow" title="查看easttiger的档案">
               <img src="http://sdn.geekzu.org/avatar/abaead86be3dc59380199f1e9e35c5bb?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/103183/" rel="nofollow" title="查看easttiger的档案">
               easttiger
              </a>
              <br/>
              <div class="bbp-author-role">
               版主
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               回复 第6楼 的 he_sophie： 一般直接打函数名即可看到, 如果是底层函数, 可在cran上下到源代码
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-334977">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2012年7月23日 上午2:56
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/107532/#post-334977">
               8 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-334977 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-107532 bbp-reply-position-8 user-id-376339 post-334977 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/376339/" rel="nofollow" title="查看he_sophie的档案">
               <img src="http://sdn.geekzu.org/avatar/2dd480c72937d6c7c5c9f351c0b1b439?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/376339/" rel="nofollow" title="查看he_sophie的档案">
               he_sophie
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               回复 第7楼 的 easttiger：我想看np包里面的npreg函数和npregbw函数的源代码,能不能给我一个链接?谢谢版主!
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-335018">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2012年7月23日 下午3:55
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/107532/#post-335018">
               9 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-335018 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-107532 bbp-reply-position-9 user-id-103183 post-335018 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/103183/" rel="nofollow" title="查看easttiger的档案">
               <img src="http://sdn.geekzu.org/avatar/abaead86be3dc59380199f1e9e35c5bb?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/103183/" rel="nofollow" title="查看easttiger的档案">
               easttiger
              </a>
              <br/>
              <div class="bbp-author-role">
               版主
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               回复 第8楼 的 he_sophie：
              </p>
              <pre class="highlight ">void np_regression(double * tuno, double * tord, double * tcon, double * ty,
                   double * euno, double * eord, double * econ, double * ey,
                   double * rbw,
                   double * mcv, double * padnum,
                   int * myopti,
                   double * cm, double * cmerr, double * g, double *gerr,
                   double * xtra){
  double * vector_scale_factor, * ecm, * ecmerr, ** eg, **egerr;
  double * lambda, ** matrix_bandwidth;
  double RS, MSE, MAE, MAPE, CORR, SIGN, pad_num;
  int i,j, num_var;
  int ey_is_ty, do_grad, train_is_eval, num_obs_eval_alloc, max_lev;
  /* match integer options with their globals */
  num_reg_continuous_extern = myopti[REG_NCONI];
  num_reg_unordered_extern = myopti[REG_NUNOI];
  num_reg_ordered_extern = myopti[REG_NORDI];
  num_var = num_reg_ordered_extern + num_reg_continuous_extern + num_reg_unordered_extern;
  train_is_eval = myopti[REG_TISEI];
  ey_is_ty = myopti[REG_EY];
  num_obs_train_extern = myopti[REG_TNOBSI];
  num_obs_eval_extern = myopti[REG_ENOBSI];
  if(train_is_eval &amp;&amp; (num_obs_eval_extern != num_obs_train_extern)){
    REprintf("\n(np_regression): consistency check failed, train_is_eval but num_obs_train_extern != num_obs_eval_extern. bailing\n");
    error("\n(np_regression): consistency check failed, train_is_eval but num_obs_train_extern != num_obs_eval_extern. bailing\n");
  }
  KERNEL_reg_extern = myopti[REG_CKRNEVI];
  KERNEL_reg_unordered_extern = myopti[REG_UKRNEVI];
  KERNEL_reg_ordered_extern = myopti[REG_OKRNEVI];
  int_LARGE_SF = myopti[REG_LSFI];
  int_MINIMIZE_IO = myopti[REG_MINIOI];
  BANDWIDTH_reg_extern = myopti[REG_BWI];
  do_grad = myopti[REG_GRAD];
  int_ll_extern = myopti[REG_LL];
  max_lev = myopti[REG_MLEVI];
  pad_num = *padnum;
#ifdef MPI2
  num_obs_eval_alloc = MAX(ceil((double) num_obs_eval_extern / (double) iNum_Processors),1)*iNum_Processors;
#else
  num_obs_eval_alloc = num_obs_eval_extern;
#endif
  /* Allocate memory for objects */
  matrix_X_unordered_train_extern = alloc_matd(num_obs_train_extern, num_reg_unordered_extern);
  matrix_X_ordered_train_extern = alloc_matd(num_obs_train_extern, num_reg_ordered_extern);
  matrix_X_continuous_train_extern = alloc_matd(num_obs_train_extern, num_reg_continuous_extern);
  vector_Y_extern = alloc_vecd(num_obs_train_extern);
  if(!train_is_eval){
    matrix_X_unordered_eval_extern = alloc_matd(num_obs_eval_extern, num_reg_unordered_extern);
    matrix_X_ordered_eval_extern = alloc_matd(num_obs_eval_extern, num_reg_ordered_extern);
    matrix_X_continuous_eval_extern = alloc_matd(num_obs_eval_extern, num_reg_continuous_extern);
    if(!ey_is_ty)
      vector_Y_eval_extern = alloc_vecd(num_obs_eval_extern);
    else
      vector_Y_eval_extern = NULL;
  } else {
    matrix_X_unordered_eval_extern = matrix_X_unordered_train_extern;
    matrix_X_ordered_eval_extern = matrix_X_ordered_train_extern;
    matrix_X_continuous_eval_extern = matrix_X_continuous_train_extern;
    if(!ey_is_ty)
      vector_Y_eval_extern = alloc_vecd(num_obs_eval_extern);
    else
      vector_Y_eval_extern = vector_Y_extern;
  }
  ecm = alloc_vecd(num_obs_eval_alloc);
  ecmerr = alloc_vecd(num_obs_eval_alloc);
  eg = alloc_matd(num_obs_eval_alloc, num_var);
  egerr = alloc_matd(num_obs_eval_alloc, num_var);
  num_categories_extern = alloc_vecu(num_reg_unordered_extern+num_reg_ordered_extern);
  vector_scale_factor = alloc_vecd(num_var + 1);
  matrix_categorical_vals_extern = alloc_matd(max_lev, num_reg_unordered_extern + num_reg_ordered_extern);
  lambda =  alloc_vecd(num_reg_unordered_extern+num_reg_ordered_extern);
  matrix_bandwidth = alloc_matd((BANDWIDTH_reg_extern==BW_GEN_NN)?num_obs_eval_extern:
                                ((BANDWIDTH_reg_extern==BW_ADAP_NN)?num_obs_train_extern:1),num_reg_continuous_extern);  
  /* train */
  for( j=0;j&lt;num_reg_unordered_extern;j++)
    for( i=0;i&lt;num_obs_train_extern;i++ )
      matrix_X_unordered_train_extern[j][i]=tuno[j*num_obs_train_extern+i];
  for( j=0;j&lt;num_reg_ordered_extern;j++)
    for( i=0;i&lt;num_obs_train_extern;i++ )
      matrix_X_ordered_train_extern[j][i]=tord[j*num_obs_train_extern+i];
  for( j=0;j&lt;num_reg_continuous_extern;j++)
    for( i=0;i&lt;num_obs_train_extern;i++ )
      matrix_X_continuous_train_extern[j][i]=tcon[j*num_obs_train_extern+i];
  for( i=0;i&lt;num_obs_train_extern;i++ )
    vector_Y_extern[i] = ty[i];
  /* eval */
  if(!train_is_eval){
    for( j=0;j&lt;num_reg_unordered_extern;j++)
      for( i=0;i&lt;num_obs_eval_extern;i++ )
        matrix_X_unordered_eval_extern[j][i]=euno[j*num_obs_eval_extern+i];
    for( j=0;j&lt;num_reg_ordered_extern;j++)
      for( i=0;i&lt;num_obs_eval_extern;i++ )
        matrix_X_ordered_eval_extern[j][i]=eord[j*num_obs_eval_extern+i];
    for( j=0;j&lt;num_reg_continuous_extern;j++)
      for( i=0;i&lt;num_obs_eval_extern;i++ )
        matrix_X_continuous_eval_extern[j][i]=econ[j*num_obs_eval_extern+i];
  }
  if(!ey_is_ty)
    for(i=0;i&lt;num_obs_eval_extern;i++)
      vector_Y_eval_extern[i] = ey[i];
  /*  bandwidths/scale factors */
  for( i=0; i&lt;num_var; i++ )
    vector_scale_factor[i+1] = rbw[i];
  /* fix up categories */
  for(j=0; j &lt; (num_reg_unordered_extern + num_reg_ordered_extern); j++){
    i = 0;
    do {
      matrix_categorical_vals_extern[j][i] = mcv[j*max_lev+i];
    } while(++i &lt; max_lev &amp;&amp; mcv[j*max_lev+i] != pad_num);
    num_categories_extern[j] = i;
  }
  /* Conduct estimation */
  /*
     nb - KERNEL_(|un)ordered_den are set to zero upon declaration
     - they have only one kernel type each at the moment
  */
  kernel_estimate_regression_categorical(int_ll_extern,
                                         KERNEL_reg_extern,
                                         KERNEL_reg_unordered_extern,
                                         KERNEL_reg_ordered_extern,
                                         BANDWIDTH_reg_extern,
                                         num_obs_train_extern,
                                         num_obs_eval_extern,
                                         num_reg_unordered_extern,
                                         num_reg_ordered_extern,
                                         num_reg_continuous_extern,
                                         /* Train */
                                         matrix_X_unordered_train_extern,
                                         matrix_X_ordered_train_extern,
                                         matrix_X_continuous_train_extern,
                                         /* Eval */
                                         matrix_X_unordered_eval_extern,
                                         matrix_X_ordered_eval_extern,
                                         matrix_X_continuous_eval_extern,
                                         /* Bandwidth */
                                         matrix_X_continuous_train_extern,
                                         vector_Y_extern,
                                         vector_Y_eval_extern,
                                         &amp;vector_scale_factor[1],
                                         num_categories_extern,
                                         ecm,
                                         eg,
                                         ecmerr,
                                         egerr,
                                         &amp;RS,
                                         &amp;MSE,
                                         &amp;MAE,
                                         &amp;MAPE,
                                         &amp;CORR,
                                         &amp;SIGN);
  if (do_grad){
    kernel_bandwidth_mean(KERNEL_reg_extern,
                          BANDWIDTH_reg_extern,
                          num_obs_train_extern,
                          num_obs_eval_extern,
                          0,
                          0,
                          0,
                          num_reg_continuous_extern,
                          num_reg_unordered_extern,
                          num_reg_ordered_extern,
                          &amp;vector_scale_factor[1],
                          /* Not used */
                          matrix_Y_continuous_train_extern,
                          /* Not used */
                          matrix_Y_continuous_train_extern,
                          matrix_X_continuous_train_extern,
                          matrix_X_continuous_eval_extern,
                          matrix_bandwidth,/* Not used */
                          matrix_bandwidth,
                          lambda);
    kernel_estimate_categorical_gradient_ocg_fast(1,
                                                  NULL,
                                                  0,
                                                  KERNEL_reg_extern,
                                                  KERNEL_reg_unordered_extern,
                                                  KERNEL_reg_ordered_extern,
                                                  BANDWIDTH_reg_extern,
                                                  int_ll_extern,
                                                  0,
                                                  num_obs_train_extern,
                                                  num_obs_eval_extern,
                                                  num_reg_unordered_extern,
                                                  num_reg_ordered_extern,
                                                  num_reg_continuous_extern,
                                                  vector_Y_extern,
                                                  matrix_X_unordered_train_extern,
                                                  matrix_X_ordered_train_extern,
                                                  matrix_X_continuous_train_extern,
                                                  matrix_X_unordered_eval_extern,
                                                  matrix_X_ordered_eval_extern,
                                                  matrix_X_continuous_eval_extern,
                                                  matrix_bandwidth,
                                                  NULL,
                                                  lambda,
                                                  num_categories_extern,
                                                  matrix_categorical_vals_extern,
                                                  ecm,
                                                  &amp;eg[num_reg_continuous_extern]);
  }
  /* write the return values */
  for(i=0;i&lt;num_obs_eval_extern;i++)
    cm[i] = ecm[i];
  for(i=0;i&lt;num_obs_eval_extern;i++)
    cmerr[i] = ecmerr[i];
  if(do_grad){
    for(j=0;j&lt;num_var;j++)
      for(i=0;i&lt;num_obs_eval_extern;i++)
        g[j*num_obs_eval_extern+i]=eg[j][i];
    for(j=0;j&lt;num_reg_continuous_extern;j++)
      for(i=0;i&lt;num_obs_eval_extern;i++)
        gerr[j*num_obs_eval_extern+i]=egerr[j][i];
  }
  xtra[0] = RS;
  xtra[1] = MSE;
  xtra[2] = MAE;
  xtra[3] = MAPE;
  xtra[4] = CORR;
  xtra[5] = SIGN;
  /* clean up and wave goodbye */
  free_mat(matrix_X_unordered_train_extern, num_reg_unordered_extern);
  free_mat(matrix_X_ordered_train_extern, num_reg_ordered_extern);
  free_mat(matrix_X_continuous_train_extern, num_reg_continuous_extern);
  if(!train_is_eval){
    free_mat(matrix_X_unordered_eval_extern, num_reg_unordered_extern);
    free_mat(matrix_X_ordered_eval_extern, num_reg_ordered_extern);
    free_mat(matrix_X_continuous_eval_extern, num_reg_continuous_extern);
  }
  free_mat(eg, num_var);
  free_mat(egerr, num_var);
  free_mat(matrix_bandwidth, num_reg_continuous_extern);
  free_mat(matrix_categorical_vals_extern, num_reg_unordered_extern+num_reg_ordered_extern);
  safe_free(vector_Y_extern);
  if(!ey_is_ty)
    safe_free(vector_Y_eval_extern);
  safe_free(ecm);
  safe_free(ecmerr);
  safe_free(num_categories_extern);
  safe_free(vector_scale_factor);
  safe_free(lambda);
  return;
}
</pre>
              <p>
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-335019">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2012年7月23日 下午3:56
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/107532/#post-335019">
               10 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-335019 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-107532 bbp-reply-position-10 user-id-103183 post-335019 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/103183/" rel="nofollow" title="查看easttiger的档案">
               <img src="http://sdn.geekzu.org/avatar/abaead86be3dc59380199f1e9e35c5bb?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/103183/" rel="nofollow" title="查看easttiger的档案">
               easttiger
              </a>
              <br/>
              <div class="bbp-author-role">
               版主
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
              </p>
              <pre class="highlight ">void np_regression_bw(double * runo, double * rord, double * rcon, double * y,
                      int * myopti, double * myoptd, double * rbw, double * fval){
  //KDT * kdt = NULL; // tree structure
  //NL nl = { .node = NULL, .n = 0, .nalloc = 0 };// a node list structure -- used for searching - here for testing
  //double tb[4] = {0.25, 0.5, 0.3, 0.75};
  int * ip = NULL;  // point permutation, see tree.c
  double **matrix_y;
  double *vector_continuous_stddev;
  double *vector_scale_factor, *vector_scale_factor_multistart;
  double fret, fret_best;
  double ftol, tol, small;
  double (* bwmfunc)(double *);
  int i,j;
  int num_var;
  int iMultistart, iMs_counter, iNum_Multistart, iImproved;
  int itmax, iter;
  int int_use_starting_values;
  num_reg_continuous_extern = myopti[RBW_NCONI];
  num_reg_unordered_extern = myopti[RBW_NUNOI];
  num_reg_ordered_extern = myopti[RBW_NORDI];
  num_var = num_reg_ordered_extern + num_reg_continuous_extern + num_reg_unordered_extern;
  num_obs_train_extern = myopti[RBW_NOBSI];
  iMultistart = myopti[RBW_IMULTII];
  iNum_Multistart = myopti[RBW_NMULTII];
  KERNEL_reg_extern = myopti[RBW_CKRNEVI];
  KERNEL_reg_unordered_extern = myopti[RBW_UKRNEVI];
  KERNEL_reg_ordered_extern = myopti[RBW_OKRNEVI];
  int_use_starting_values= myopti[RBW_USTARTI];
  int_LARGE_SF=myopti[RBW_LSFI];
  BANDWIDTH_reg_extern=myopti[RBW_REGI];
  BANDWIDTH_den_extern=0;
  itmax=myopti[RBW_ITMAXI];
  int_RESTART_FROM_MIN = myopti[RBW_REMINI];
  int_MINIMIZE_IO = myopti[RBW_MINIOI];
  int_ll_extern = myopti[RBW_LL];
  int_TREE = myopti[RBW_DOTREEI];
  ftol=myoptd[RBW_FTOLD];
  tol=myoptd[RBW_TOLD];
  small=myoptd[RBW_SMALLD];
  imsnum = 0;
  imstot = iNum_Multistart;
  /* Allocate memory for objects */
  matrix_X_unordered_train_extern = alloc_matd(num_obs_train_extern, num_reg_unordered_extern);
  matrix_X_ordered_train_extern = alloc_matd(num_obs_train_extern, num_reg_ordered_extern);
  matrix_X_continuous_train_extern = alloc_matd(num_obs_train_extern, num_reg_continuous_extern);
  vector_Y_extern = alloc_vecd(num_obs_train_extern);
  num_categories_extern = alloc_vecu(num_reg_unordered_extern+num_reg_ordered_extern);
  matrix_y = alloc_matd(num_var + 1, num_var +1);
  vector_scale_factor = alloc_vecd(num_var + 1);
  matrix_categorical_vals_extern = alloc_matd(num_obs_train_extern, num_reg_unordered_extern + num_reg_ordered_extern);
  vector_continuous_stddev = alloc_vecd(num_reg_continuous_extern);
  /* Request starting values for optimization if values already exist */
  /* bandwidths */
  if (int_use_starting_values)
    for( i=0;i&lt;num_var; i++ )
      vector_scale_factor[i+1] = rbw[i];
  /* regressors */
  for( j=0;j&lt;num_reg_unordered_extern;j++)
    for( i=0;i&lt;num_obs_train_extern;i++ )
      matrix_X_unordered_train_extern[j][i]=runo[j*num_obs_train_extern+i];
  for( j=0;j&lt;num_reg_ordered_extern;j++)
    for( i=0;i&lt;num_obs_train_extern;i++ )
      matrix_X_ordered_train_extern[j][i]=rord[j*num_obs_train_extern+i];
  for( j=0;j&lt;num_reg_continuous_extern;j++)
    for( i=0;i&lt;num_obs_train_extern;i++ )
      matrix_X_continuous_train_extern[j][i]=rcon[j*num_obs_train_extern+i];
  /* response variable */
  for( i=0;i&lt;num_obs_train_extern;i++ )
    vector_Y_extern[i] = y[i];
  // attempt tree build, if enabled
  int_TREE = int_TREE &amp;&amp; ((num_reg_continuous_extern != 0) ? NP_TREE_TRUE : NP_TREE_FALSE);
  if(int_TREE == NP_TREE_TRUE){
    build_kdtree(matrix_X_continuous_train_extern, num_obs_train_extern, num_reg_continuous_extern,
		 4*num_reg_continuous_extern, &amp;ip, &amp;kdt_extern);
    //put training data into tree-order using the index array
    for( j=0;j&lt;num_reg_unordered_extern;j++)
      for( i=0;i&lt;num_obs_train_extern;i++ )
	matrix_X_unordered_train_extern[j][i]=runo[j*num_obs_train_extern+ip[i]];
    for( j=0;j&lt;num_reg_ordered_extern;j++)
      for( i=0;i&lt;num_obs_train_extern;i++ )
	matrix_X_ordered_train_extern[j][i]=rord[j*num_obs_train_extern+ip[i]];
    for( j=0;j&lt;num_reg_continuous_extern;j++)
      for( i=0;i&lt;num_obs_train_extern;i++ )
	matrix_X_continuous_train_extern[j][i]=rcon[j*num_obs_train_extern+ip[i]];
    /* response variable */
    for( i=0;i&lt;num_obs_train_extern;i++ )
      vector_Y_extern[i] = y[ip[i]];
    //boxSearch(kdt_extern, 0, tb, &amp;nl);
  }
  determine_categorical_vals(
                             num_obs_train_extern,
                             0,
                             0,
                             num_reg_unordered_extern,
                             num_reg_ordered_extern,
                             matrix_Y_unordered_train_extern,
                             matrix_Y_ordered_train_extern,
                             matrix_X_unordered_train_extern,
                             matrix_X_ordered_train_extern,
                             num_categories_extern,
                             matrix_categorical_vals_extern);
  compute_continuous_stddev(
                            int_LARGE_SF,
                            num_obs_train_extern,
                            0,
                            num_reg_continuous_extern,
                            matrix_Y_continuous_train_extern,
                            matrix_X_continuous_train_extern,
                            vector_continuous_stddev);
  /* Initialize scale factors and Hessian for NR modules */
  initialize_nr_vector_scale_factor(
                                    BANDWIDTH_reg_extern,
                                    BANDWIDTH_den_extern,
                                    0,                /* Not Random (0) Random (1) */
                                    int_RANDOM_SEED,
                                    0,                /* regression (0) regression ml (1) */
                                    int_LARGE_SF,
                                    num_obs_train_extern,
                                    0,
                                    0,
                                    0,
                                    num_reg_continuous_extern,
                                    num_reg_unordered_extern,
                                    num_reg_ordered_extern,
                                    matrix_Y_continuous_train_extern,
                                    matrix_X_continuous_train_extern,
                                    int_use_starting_values,
                                    pow((double)4.0/(double)3.0,0.2),             /* Init for continuous vars */
                                    num_categories_extern,
                                    vector_continuous_stddev,
                                    vector_scale_factor);
  initialize_nr_hessian(num_var, matrix_y);
  /* When multistarting, set counter */
  iMs_counter = 0;
  /* assign the function to be optimized */
  switch(myopti[RBW_MI]){
  case RBWM_CVAIC : bwmfunc = cv_func_regression_categorical_aic_c; break;
  case RBWM_CVLS : bwmfunc = cv_func_regression_categorical_ls; break;
  default : REprintf("np.c: invalid bandwidth selection method.");
    error("np.c: invalid bandwidth selection method.");break;
  }
  spinner(0);
  fret_best = bwmfunc(vector_scale_factor);
  iImproved = 0;
  powell(0,
         0,
         vector_scale_factor,
         vector_scale_factor,
         matrix_y,
         num_var,
         ftol,
         tol,
         small,
         itmax,
         &amp;iter,
         &amp;fret,
         bwmfunc);
  if(int_RESTART_FROM_MIN == RE_MIN_TRUE){
    initialize_nr_hessian(num_var, matrix_y);
    powell(0,
           0,
           vector_scale_factor,
           vector_scale_factor,
           matrix_y,
           num_var,
           ftol,
           tol,
           small,
           itmax,
           &amp;iter,
           &amp;fret,
           bwmfunc);
  }
  iImproved = (fret &lt; fret_best);
  /* When multistarting save initial minimum of objective function and scale factors */
  if(iMultistart == IMULTI_TRUE){
    fret_best = fret;
    vector_scale_factor_multistart = alloc_vecd(num_var + 1);
    for(i = 1; i &lt;= num_var; i++)
      vector_scale_factor_multistart[i] = (double) vector_scale_factor[i];
    /* Conduct search from new random values of the search parameters */
    for(imsnum = iMs_counter = 1; iMs_counter &lt; iNum_Multistart; imsnum++,iMs_counter++){
      /* Initialize scale factors and hessian for NR modules */
      initialize_nr_vector_scale_factor(BANDWIDTH_reg_extern,
                                        BANDWIDTH_den_extern,
                                        1,        /* Not Random (0) Random (1) */
                                        int_RANDOM_SEED,
                                        0,        /* regression (0) regression ml (1) */
                                        int_LARGE_SF,
                                        num_obs_train_extern,
                                        0,
                                        0,
                                        0,
                                        num_reg_continuous_extern,
                                        num_reg_unordered_extern,
                                        num_reg_ordered_extern,
                                        matrix_Y_continuous_train_extern,
                                        matrix_X_continuous_train_extern,
                                        int_use_starting_values,
                                        pow((double)4.0/(double)3.0,0.2),     /* Init for continuous vars */
                                        num_categories_extern,
                                        vector_continuous_stddev,
                                        vector_scale_factor);
      initialize_nr_hessian(num_var, matrix_y);
      /* Conduct direction set search */
      powell(0,
             0,
             vector_scale_factor,
             vector_scale_factor,
             matrix_y,
             num_var,
             ftol,
             tol,
             small,
             itmax,
             &amp;iter,
             &amp;fret,
             bwmfunc);
      if(int_RESTART_FROM_MIN == RE_MIN_TRUE)	{
        initialize_nr_hessian(num_var, matrix_y);
        powell(0,
               0,
               vector_scale_factor,
               vector_scale_factor,
               matrix_y,
               num_var,
               ftol,
               tol,
               small,
               itmax,
               &amp;iter,
               &amp;fret,
               bwmfunc);
      }
      /* If this run resulted in an improved minimum save information */
      if(fret &lt; fret_best){
        fret_best = fret;
        iImproved = iMs_counter+1;
        for(i = 1; i &lt;= num_var; i++)
          vector_scale_factor_multistart[i] = (double) vector_scale_factor[i];
      }
    }
    /* Save best for estimation */
    fret = fret_best;
    for(i = 1; i &lt;= num_var; i++)
      vector_scale_factor[i] = (double) vector_scale_factor_multistart[i];
    free(vector_scale_factor_multistart);
  }
  /* return data to R */
  if (BANDWIDTH_reg_extern == BW_GEN_NN ||
      BANDWIDTH_reg_extern == BW_ADAP_NN){
    for( i=0; i&lt;num_reg_continuous_extern; i++ )
      vector_scale_factor[i+1]=fround(vector_scale_factor[i+1]);
  }
  for( i=0; i&lt;num_var; i++ )
    rbw[i]=vector_scale_factor[i+1];
  fval[0] = fret;
  fval[1] = iImproved;
  /* end return data */
  /* Free data objects */
  free_mat(matrix_X_unordered_train_extern, num_reg_unordered_extern);
  free_mat(matrix_X_ordered_train_extern, num_reg_ordered_extern);
  free_mat(matrix_X_continuous_train_extern, num_reg_continuous_extern);
  safe_free(vector_Y_extern);
  free_mat(matrix_y, num_var + 1);
  safe_free(vector_scale_factor);
  safe_free(num_categories_extern);
  free_mat(matrix_categorical_vals_extern, num_reg_unordered_extern+num_reg_ordered_extern);
  free(vector_continuous_stddev);
  if(int_TREE == NP_TREE_TRUE){
    free(ip);
    ip = NULL;
    free_kdtree(&amp;kdt_extern);
    int_TREE = NP_TREE_FALSE;
  }
  if(int_MINIMIZE_IO != IO_MIN_TRUE)
    Rprintf("\r                   \r");
  //fprintf(stderr,"\nNP TOASTY\n");
  return ;
}
</pre>
              <p>
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-335594">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2012年8月7日 上午7:59
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/107532/#post-335594">
               11 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-335594 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-107532 bbp-reply-position-11 user-id-376339 post-335594 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/376339/" rel="nofollow" title="查看he_sophie的档案">
               <img src="http://sdn.geekzu.org/avatar/2dd480c72937d6c7c5c9f351c0b1b439?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/376339/" rel="nofollow" title="查看he_sophie的档案">
               he_sophie
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               谢谢版主！我还有一个问题：
               <br/>
               在npreg中做预测的时候，怎么会出现newdata与变量数目不匹配的问题？需要预测的期数肯定与训练样本的样本容量是不一样的。具体出错信息：
               <br/>
               警告信息：
               <br/>
               ‘newdata’有2行但变量里有55行
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
           </li>
           <!-- .bbp-body -->
           <li class="bbp-footer">
            <div class="bbp-reply-author">
             作者
            </div>
            <div class="bbp-reply-content">
             帖子
            </div>
            <!-- .bbp-reply-content -->
           </li>
           <!-- .bbp-footer -->
          </ul>
          <!-- #topic-107532-replies -->
          <div class="bbp-pagination">
           <div class="bbp-pagination-count">
            查看 11 个帖子 - 1 到 11（总计 11 个）
           </div>
           <div class="bbp-pagination-links">
           </div>
          </div>
          <div class="bbp-no-reply" id="no-reply-107532">
           <div class="bbp-template-notice">
            <p>
             您必须先登录才能回复该主题。
            </p>
           </div>
          </div>
         </div>
        </div>
        <!-- .entry-content -->
        <footer class="entry-meta">
        </footer>
        <!-- .entry-meta -->
       </article>
       <!-- #post -->
       <div class="comments-area" id="comments">
       </div>
       <!-- #comments -->
      </div>
      <!-- #content -->
     </div>
     <!-- #primary -->
     <div class="sidebar-container" id="tertiary" role="complementary">
      <div class="sidebar-inner">
       <div class="widget-area">
        <aside class="widget bbp_widget_login" id="bbp_login_widget-2">
         <h3 class="widget-title">
          登录
         </h3>
         <form action="http://cos.name/cn/wp-login.php" class="bbp-login-form" method="post">
          <fieldset>
           <legend>
            登录
           </legend>
           <div class="bbp-username">
            <label for="user_login">
             用户名:
            </label>
           </div>
           <div class="bbp-password">
            <label for="user_pass">
             密码:
            </label>
           </div>
           <div class="bbp-remember-me">
            <label for="rememberme">
             记住用户名
            </label>
           </div>
           <div class="bbp-submit-wrapper">
            <button class="button submit user-submit" id="user-submit" name="user-submit" tabindex="104" type="submit">
             登录
            </button>
           </div>
           <div class="bbp-login-links">
            <a class="bbp-register-link" href="http://cos.name/cn/wp-login.php?action=register" title="注册">
             注册
            </a>
            <a class="bbp-lostpass-link" href="http://cos.name/cn/wp-login.php?action=lostpassword" title="忘记密码">
             忘记密码
            </a>
           </div>
          </fieldset>
         </form>
        </aside>
        <aside class="widget widget_text" id="text-7">
         <h3 class="widget-title">
          搜索
         </h3>
         <div class="textwidget">
          <form action="http://www.google.com/search" id="bbp-search-form" method="get" onsubmit="Gsitesearch(this)" role="search">
           <div>
           </div>
          </form>
          <form id="bbp-search-form-baidu" onsubmit="g(this)" role="search">
           <div>
           </div>
          </form>
         </div>
        </aside>
        <aside class="widget widget_text" id="text-2">
         <h3 class="widget-title">
          新鲜事
         </h3>
         <div class="textwidget">
          <ul>
           <li>
            <a href="http://cos.name/cn/topics/">
             最新帖子
            </a>
           </li>
           <li>
            <a href="http://cos.name/cn/view/popular/">
             最热门主题
            </a>
           </li>
           <li>
            <a href="http://cos.name/cn/view/no-replies/">
             消灭零回复
            </a>
           </li>
          </ul>
         </div>
        </aside>
        <aside class="widget widget_text" id="text-3">
         <h3 class="widget-title">
          RSS订阅
         </h3>
         <div class="textwidget">
          <ul>
           <li>
            <img src="http://cos.name/wp-includes/images/rss.png"/>
            <a href="http://cos.name/cn/topics/feed/">
             所有主题
            </a>
           </li>
           <li>
            <img src="http://cos.name/wp-includes/images/rss.png"/>
            <a href="http://cos.name/cn/forums/feed/">
             所有帖子
            </a>
           </li>
          </ul>
         </div>
        </aside>
       </div>
       <!-- .widget-area -->
      </div>
      <!-- .sidebar-inner -->
     </div>
     <!-- #tertiary -->
    </div>
    <!-- #main -->
    <footer class="site-footer" id="colophon" role="contentinfo">
     <div class="site-info">
      版权所有 © 2014 统计之都 | 由
      <a href="http://wordpress.org/">
       WordPress
      </a>
      构建 | 主题修改自
      <a href="http://wordpress.org/themes/twentythirteen">
       Twenty Thirteen
      </a>
     </div>
     <!-- .site-info -->
    </footer>
    <!-- #colophon -->
   </div>
   <!-- #page -->
  </div>
 </body>
</html>